<style>
#load{
    width:100%;
    height:100%;
    position:fixed;
    z-index:9999;
    background:url("images/loading_bar.gif") no-repeat center center #fff;
}
</style>
<script>
document.onreadystatechange = function (){
	var path = window.location.href;
    path = path.replace(/\/$/, "");
    path = decodeURIComponent(path);
	var pageUrl		=	path;
	sessionStorage.setItem( 'pageUrl', JSON.stringify(pageUrl) );
  
  var state = document.readyState
  if (state == 'interactive') {
       document.getElementById('contents').style.visibility="hidden";
  } else if (state == 'complete') {
      setTimeout(function(){
	   if(typeof sessionStorage["admin_user_id"]!='undefined'){
			document.getElementById('interactive');
			document.getElementById('load').style.visibility="hidden";
			document.getElementById('contents').style.visibility="visible";
		 }else{
			window.location="index.html";
		 }
      },300);
  }
}
</script>
<script src="js/chart.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.pagination.js"></script> 
<script src="js/webserviceurl.js"></script>
<script src="js/alert.js"></script>
<script src="js/modal.js"></script>
<script src="js/validations.js"></script>
<script src="js/pagination.js"></script>
<script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap-carousel.js"></script>
<script src="js/commonfunctions.js"></script>
<script src="js/text.js"></script>
<link rel="stylesheet" href="css/pagination.css" />
<link href="css/style.css" rel="stylesheet">
<link href="css/default.css" rel="stylesheet">
<link href="css/responsive.css" rel="stylesheet">
<script type="text/javascript">
	google.load('visualization', '1', {packages: ['corechart']});
	$(function() {
		$('#sidemenu').load('side-menu.html');
		$('#header').load('header.html');
		$('#footer').load('footer.html');
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'admin-all-shops',
			dataType	: 	"json",	
			data		:   {status:1,type_id:3},	
			success: function(data){
				var getuserslist;
				var obj = eval("(" + data.result + ")");
				$.each(obj, function (index,Object){					
					getuserslist +='<option  value="'+Object.user_id+'">'+Object.user_name+'</option>';
				});
				$('#user_id').html(getuserslist);
				var user_id = $("#user_id").val();
				usersOrders();
			}
		});		
	});
	function usersOrders(){			
		var shop_id = $("#user_id").val();
		$('#visualization').html('Please wait loading....');
		$('#visualization1').html('Please wait loading....');
		$.ajax({
			type		:	'GET',
			url			:  	webServiceUrl+'shop-com-rp-rv-rtng/shop-'+shop_id,
			dataType	: 	"json",			
			success: function(data){
				$('#ratingsHide').show();
				if(data.cntRating1!=0){
					$('#stars1').html(data.cntRating1);	
				}else{
					$('#stars1').html(0);	
				}if(data.cntRating2!=0 ){
					$('#stars2').html(data.cntRating2);	
				}else{
					$('#stars2').html(0);	
				}if(data.cntRating3!=0 ) {
					$('#stars3').html(data.cntRating3);	
				}else{
					$('#stars3').html(0);	
				}if(data.cntRating4!=0) {
					$('#stars4').html(data.cntRating4);
				}else{
					$('#stars4').html(0);
				}if(data.cntRating5!=0){
					$('#stars').html(data.cntRating5);		
				}else{
					$('#stars5').html(0);
				}
				if(data.cntRating5==0 && data.cntRating4==0 && data.cntRating3==0 && data.cntRating2==0 && data.cntRating1==0 ){
					$('#ratingsHide').hide();
				}
				if( data.cntComplanits!=0 || data.cntReplies!=0 || data.cntReviews!=0 ){
					var json='[["shop", "reports"],';					
					var finall='';
					finall=finall+'["Complaints",'+data.cntComplanits+']'+','+'["Repliesofcomplaints",'+data.cntReplies+']'+','+'["Reviews",'+data.cntReviews+']';				
					finall=finall.replace(/,\s*$/, ",");
					json+=finall+']';
					var data = google.visualization.arrayToDataTable($.parseJSON(json));					 
					new google.visualization.PieChart(document.getElementById('visualization')).
					draw(data, {title:"Shop Complaints, Reviews and Orders "});														
				}else{						
					$('#visualization').html('No reports....');
				}
				$.ajax({
					type		:	'POST',
					url			:  	webServiceUrl+'shop-orders',
					dataType	: 	"json",			
					data	    : 	{shop_id:shop_id},			
					success: function(data){
						if( data.totOrders!=0 || data.totrenewalOrders!=0 || data.totSentorders!=0 || data.totConfirmedOrders!=0 || data.totDeliveredOrders!=0 || data.totunPaidOrders!=0 || data.totPaidOrders!=0){
								var json='[["shop", "reports"],';					
								var finall='';
								finall=finall+'["TotalOrders",'+data.totOrders+']'+','+'["TotRenewalOrders",'+data.totrenewalOrders+']'+','+'["SentpriceToAdmin",'+data.totSentorders+']'+','+'["ConfirmedOrders",'+data.totConfirmedOrders+']'+','+'["DeliveredOrders",'+data.totDeliveredOrders+']'+','+'["DiscountsUnpaidToAdmin",'+data.totunPaidOrders+']'+','+'["DiscountsPaidToAdmin",'+data.totPaidOrders+']';				
								finall=finall.replace(/,\s*$/, ",");
								json+=finall+']';
								var data = google.visualization.arrayToDataTable($.parseJSON(json));					 
								new google.visualization.PieChart(document.getElementById('visualization1')).
								draw(data, {title:"Shop Orders Reports"});														
							}else{						
								$('#visualization1').html('No reports....');
							}	
					}				
				});	
			}
		});
	}
</script>
<div id="load"></div>
<div id="contents">
  <div id="header"></div>
    <div class="container-fluid">
      <div class="row-fluid container_bg">
      <div id="sidemenu"></div>
        <div class="span9">
			<div class="container_title" style="position:relative;">
				<div class=""><h1>Admin Reports</h1></div>
				<a href='reports.html'>Date Wise Orders</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href='total-users-orders.html'>Users Orders Report</a>
				&nbsp;&nbsp;|&nbsp;&nbsp;<a href='total-users-report.html'>Total Users Report</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href='shop-wise-reports.html'> Shop wise performance reports</a><br/><br/>
				Select shop:<select id="user_id" name="user_id" onchange="usersOrders()"></select>
				<div class="container_form_top">
					<div class="row">
						<div id="visualization" style="width: 100%; height: 400px;"></div>
						<div id='ratingsHide' style="position: absolute; right: 24.5%; top: 35%; display:none;">
							<label class="control-label" for="rating"><b>Ratings</b> :</label>
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">&nbsp;&nbsp;&nbsp;<span id="stars5"></span><br/>	<br/>					
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/gray-star.png">&nbsp;&nbsp;&nbsp;<span id="stars4"></span><br/>	<br/>	
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/gray-star.png">
						<img class="star" src="images/gray-star.png">&nbsp;&nbsp;&nbsp;<span id="stars3"></span><br/>	<br/>	
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/gray-star.png">
						<img class="star" src="images/gray-star.png">
						<img class="star" src="images/gray-star.png">&nbsp;&nbsp;&nbsp;<span id="stars2"></span><br/>	<br/>	
						<img class="star" src="images/green-star.png">
						<img class="star" src="images/gray-star.png">
						<img class="star" src="images/gray-star.png">
						<img class="star" src="images/gray-star.png">
						<img class="star" src="images/gray-star.png">&nbsp;&nbsp;&nbsp;<span id="stars1"></span>	
						</div>
					</div>
					<div class="row">
						<div id="visualization1" style="width: 100%; height: 400px;"></div>
					</div>
				</div>
			</div>
        </div>
      </div>
    </div>
<div id="footer"></div>
</div>
 <link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
